package com.summer.framework.base.exception;

import com.summer.framework.base.result.ResultError;
import lombok.Getter;

/**
 * Description: 非受检异常
 * @auther Ice Yang
 * Date 2025/7/24 11:15
 */
@Getter
public class SummerRuntimeException extends RuntimeException{

    private int code;
    private String messageKey;
    private String message;
    private Object[] args;

    public SummerRuntimeException() {
        super();
    }

    public SummerRuntimeException(String message) {
        super(message);
        this.message = message;
    }

    public SummerRuntimeException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }

    public SummerRuntimeException(Throwable cause) {
        super(cause);
        this.message = cause.getMessage();
    }

    public SummerRuntimeException(ResultError error) {
        super(error.getMessage());
        this.code = error.getCode();
        this.messageKey = error.getKey();
        this.message = error.getMessage();
    }

    public SummerRuntimeException(ResultError error,Object... args) {
        super(error.getMessage());
        this.code = error.getCode();
        this.messageKey = error.getKey();
        this.message = error.getMessage();
        this.args = args;
    }

    protected SummerRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.message = message;
    }
}
